Component({
  // 外部样式覆盖
  externalClasses: ['txt', 'follow-status'],
  options: {

  },
  /**
   * 组件的属性列表
   */
  properties: {
    item: {
      type: Object,
      value: {},
      observer: function (newVal, oldVal) {
        const ExpireDate = newVal.changedDate || newVal.goodsDeliveryDate;
        let now = new Date().getTime();
        const expire = new Date(ExpireDate).setHours(23, 59, 59);
        if (now > expire && newVal.deliverStatus == 0) { // 已延期
          this.setData({
            isOverdue: 1
          });
        } else {
          now = new Date(now).setHours(23, 59, 59);
          let diff = expire - now;
          if (diff >= 0 && diff <= 3 * 24 * 3600 * 1000 && newVal.deliverStatus == 0) { //即将延期
            this.setData({
              isOverdue: 2
            });
          }
        }

      }

    },
    listIndex: {
      type: Number,
      value: 0,
      observer: function (e) {},
    },
    isShare: {
      type: Boolean,
      value: false,
      observer: function (e) {},
    },
    hasFooter: {
      type: Boolean,
      value: true
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    isOverdue: 0
  },

  /**
   * 组件的方法列表
   */
  methods: {
    cancelOrder(e) {
      this.triggerEvent('cancel', {
        index: e.target.dataset.index,
        id: e.target.dataset.id
      })
    },
    finishOrder(e) {
      this.triggerEvent('finish', {
        index: e.target.dataset.index,
        id: e.target.dataset.id
      })
    },
    gotoDetail(e) {
      wx.navigateTo({
        url: '/pages/order/orderDetail/orderDetail?id=' + e.currentTarget.dataset.id
      })
    }
  }
})